package br.com.proescola.dao;

import br.com.proescola.db.CriaConexao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class LoginDAO {

    private Connection conexao;

    public LoginDAO() throws SQLException {
        this.conexao = CriaConexao.getConexao();
    }

    public String doLogin(String senha, String login) throws SQLException {
        //Prepara a estrutura da Query e declara o objeto PreparedStatement
        String sql = "SELECT id FROM login WHERE login = ? AND senha = ?";
        PreparedStatement stmt = conexao.prepareStatement(sql);
        ResultSet rs = stmt.executeQuery();
        //Seta os valores que vão ser inseridos na Query
        stmt.setString(1, login);
        stmt.setString(2, senha);
        //Executa a inserção SQL
        stmt.execute();
        stmt.close();

        return "oi";
    }
}
